package com.studio77.guessLyric.scene;

import android.view.KeyEvent;

import com.studio77.guessLyric.MainActivity;
import com.studio77.guessLyric.layer.GameLayer;
import com.studio77.guessLyric.util.GameUtil;
import com.wiyun.engine.nodes.Scene;

/**
 * 游戏场景
 * 
 * @author Dave
 * 
 */
public class GameScene extends Scene {

	private static GameScene instance = null;
	private static Object sync_obj = new Object();
	GameLayer layer;

	public GameLayer getLayer() {
		return layer;
	}

	protected GameScene() {
		layer = new GameLayer();
		layer.setTouchEnabled(true);
		addChild(layer);
	}

	public static GameScene make() {
		synchronized (sync_obj) {
			if (instance == null) {
				instance = new GameScene();
			}
			return instance;
		}
	}

	@Override
	public boolean wyKeyDown(KeyEvent event) {

		if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
			// 返回主菜单
			GameUtil.switchSceneTopSlide(MainScene.make());
			MainScene.make().refreshStageIndex();
			return true;
		}
		return super.wyKeyDown(event);
	}

	public void start() {
		layer.start();

	}
	
	public void updateCoinCount()
	{
		layer.updateCoinCount();
	}
}
